package April._26.answer.work3;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


public class ConfigTest {
    public static void main(String[] args) {
        Class<?> iface = Service.class;
        Class<?> clazz = ServiceImpl.class;

        if (iface.isAnnotationPresent(Config.class)) {
            System.out.println("Interface config: " + iface.getAnnotation(Config.class).value());
        }

        if (clazz.isAnnotationPresent(Config.class)) {
            System.out.println("Class config: " + clazz.getAnnotation(Config.class).value());
        }
    }
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@interface Config {
    String value();
}

@Config(value = "interface configuration")
interface Service {
    void serve();
}

@Config(value = "class configuration")
class ServiceImpl implements Service {
    public void serve() {
        System.out.println("Serving...");
    }
}
